"""
阿里云短信服务，暂时没有用上
"""

import time
import hashlib
import requests
from aliyun_sdk_core.client import AcsClient
from aliyun_sdk_core.request import CommonRequest


def send_sms(phone, code):
    url = "https://sms-service-provider.com/api/send"
    timestamp = str(int(time.time()))
    params = {
        "phone": phone,
        "code": code,
        "sign":
        hashlib.md5(f"{phone}{timestamp}secret_key".encode()).hexdigest(),
        "timestamp": timestamp
    }

    try:
        response = requests.post(url, json=params, timeout=5)
        if response.json().get("code") == 200:
            return True
        else:
            print(f"短信发送失败: {response.text}")
            return False
    except requests.exceptions.RequestException as e:
        print(f"网络错误: {str(e)}")
        return False
